package com.zrzy.Test;

public class MethodDemo {

    //接口
    interface UseString{
        String use(String str,int start,int length);
    }

    //测试方法
    public static String subAuthorName(String str, UseString useString){
        int start = 0;
        int length = 1;
        return useString.use(str,start,length);
    }


    public static void main(String[] args) {

        //优化前
        subAuthorName("三更草堂", new UseString() {
            @Override
            public String use(String str, int start, int length) {
                return str.substring(start,length);
            }
        });

        //优化后
        subAuthorName("三更草堂", String::substring);

    }
}
